package day10;

import java.util.Scanner;

public class Test04 {
public static void main(String[] args) {
	//题目：计算字符串中子串出现的次数 
	System.out.println("请输入字符串");
	Scanner sc=new Scanner(System.in);
	String str=sc.nextLine();
	System.out.println("请输入要查找的子字符串");
	String str1=sc.nextLine();
	int count=0;
	System.out.println(str+"中有"+demo(str,str1,count)+"个"+str1);
	
}
private static int demo(String str,String str1,int count) {
	
	int index=str.indexOf(str1);
	str=str.substring(index+1);
	if(index!=-1) {
		count++;
		return demo(str,str1,count);
	}else {
		return count;
	}

}
}
